﻿using H2.NET.Common;
using H2.NET.Web.Pages.SMD.Model;
using H2.NET.Web.Pages.SMD.Service;
using H2.NET.Web.Workflow.DwzCode;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace H2.NET.Web.Management.MeiPing
{
    public partial class Edit : BasePage
    {
        MeiPingService mpService = new MeiPingService();

        public t_smd_Meiping mp = new t_smd_Meiping();
        protected void Page_Load(object sender, EventArgs e)
        {
            string _action = AksRequest.GetQueryString("action");

            if (string.IsNullOrEmpty(_action))
            {
                GetMpInfo();
                return;
            }
            else
            {
                SaveMp();
            }
        }

        #region 获取实体信息=================================
        private void GetMpInfo()
        {
            int id = AksRequest.GetQueryInt("id");
            if (id == 0)
            {
                ErrorMsg("传输参数不正确！");
                return;
            }

            this.mp = mpService.GetModel(id);
        }
        #endregion

        #region 数据更新操作=================================
        private void SaveMp()
        {
            mpService.Update(new t_smd_Meiping()
            {
                ID = AksRequest.GetFormInt("id"),
                SerialNumber = AksRequest.GetFormString("SerialNumber"),
                Status = bool.Parse(AksRequest.GetFormString("Status"))
            });

            SuccessMsg("MeiPingIndex");
        }
        #endregion

    }
}